[http] sanitise URL options before use them#22186
Merged
Merged
Conversation
Test Results 22 files 22 suites 3d 10h 33m 7s ⏱️ Results for commit ab58efa. ♻️ This comment has been updated with latest results. |
jblomer
approved these changes
May 8, 2026
silverweed
reviewed
May 8, 2026
Contributor
There was a problem hiding this comment.
In general I don't think we can really trust all this code to produce properly "sanitized" input. Sanitizers are notoriously hard to get right and I see many suspicious places in the Sniffer code.
So if these checks are in place as a measure against accidental errors, they may be useful, but I wouldn't consider them a measure against actual attacks.
Regardless, I put a couple of more specific comments.
Also, we definitely need tests for this.
83b7d75 to
2b46cab
Compare
69ba55a to
c4d0d1f
Compare
silverweed
reviewed
May 19, 2026
Remove any special symbols Add escape characters for quote and escape itself Discard all URL options longer than 1K Try to avoid manipulation of arguments for method execution
Avoid special characters as draw arguments
Always use DecodeUrlOptionValue method when processing URL arguments or URL string. Internally method provides escape symbols for quotes and backslash. If expecting numeric value - remove all symbols keeping alphanumeric, '.', '+', '-' and ':'
It allows to deserialize post data as ROOT object when processing exe.json request. While this can leads to arbitrary code loading and injection, disable this feature by default. Can be enabled back with: ``` serv->SetAllowPostObject(kTRUE); ```
While here arbitrary string injected into ProcessLine, ensure that only numeric argument is not quoted. All other arguments kinds will be quoted and prevent execution of potentially dangerous code
Verify execution of several supported requests which can be handled by http server. Testing: - root.json - root.xml - file.root - exe.json - exe.json with POST data - item.json - cmd.json - multi.json Also verify basic functionality of TRootSniffer::DecodeUrlOptionValue method
This was referenced May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
URL syntax allow to provide different special symbols using
%12%20symbols.Also some situations un-escaped quotes can make a problems.
Therefore cleanup arguments from URL string adding C escape symbols.
Discard URL arguments longer than 1K
Use it in
exe.jsonandcmd.json- main place where arguments which are coming via URLare formatted for
ProcessLine.Add sophisticated check in
cmd.jsonprocessing. One need to check quotes in argument andin command definition around argument. If none exists - only simple numeric values can be injected
without quotes. Avoid double quotes on both side of argument placeholder.
Provide special flag to enable processing of post data in the
exe.json, off by default.Provide testing for the main requests processing in the sniffer.
This emulates response of
THttpServerwith same kind of http requests.